package com.guigu.gulicommon.constant;

import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.MINUTES;

/**
 * RedisKey常量
 *
 * @author 陈俊杰
 * @version 1.0
 * @since 2024/8/14 00:03
 */
public class RedisKey {
    /**
     * 用户信息redis前缀
     * <p>
     * &#064;示例   'userLoginInfo:userId'
     */
    public static final String USER_INFO_PREFIX = "userLoginInfo:";
    /**
     * 用户订单防冲令牌redis前缀
     * <p>
     * &#064;示例   'order:token:userId'
     */
    public static final String ORDER_TOKEN_PREFIX = "order:token:";
    /**
     * 订单防冲令牌过期时间
     */
    public static final Long ORDER_TOKEN_EXPIRE_TIME = 30L;
    /**
     * 订单防冲令牌过期时间单位(分)
     */
    public static final TimeUnit ORDER_TOKEN_EXPIRE_TIME_UNIT = MINUTES;


    /**
     * 验证订单防重令牌分布式锁前缀
     * <p>
     * &#064;示例   'order:token:lock:{userId}'
     */
    public static final String ORDER_TOKEN_DISTRIBUTED_LOCK_PREFIX = "order:token:lock:";
    /**
     * 验证订单防重令牌分布式锁获取超时时间
     */
    public static final long ORDER_TOKEN_DISTRIBUTED_LOCK_ACQUIRE_TIMEOUT = 1000;
    /**
     * 验证订单防重令牌分布式锁过期时间
     */
    public static final long ORDER_TOKEN_DISTRIBUTED_LOCK_EXPIRE = 10000;

    /**
     * 购物车redis前缀
     * <p>
     * &#064;示例   'cart:userId'
     */
    public static final String CART_PREFIX = "cart:";
    /**
     * 购物车过期时间
     */
    public static final Long CART_EXPIRE_TIME = 30L;
    /**
     * 购物车过期时间单位(天)
     */
    public static final TimeUnit CART_EXPIRE_TIME_UNIT = DAYS;


}
